define(['jquery'], () => {
    class Header {
        constructor () {
            this.loadHTML().then(() => {
                this.zhuzhan()
                this.welcome()
            })
        }
        loadHTML () {
            return new Promise((resolve, reject0) => {
                $('header').load('/html/modules/header.html', () => {
                    resolve()
                })
            })
        }
        zhuzhan(){
            $('#zhuzhan').on('click', function () {
                alert('尚未完工，敬请期待')
            })
        }
        welcome(){
            let user = localStorage.getItem('usermsg')
            if (user) {
                user = JSON.parse(user)
                $('.header-nav-lore').hide()
                $('.header-nav-welcome span').html(user[0].name)
                $('.header-nav-welcome').show()
            } else {
                $('.header-nav-lore').show()
                $('.header-nav-welcome').hide()
            }
        }
    }
    return new Header()
})